package com.serialization

import com.entity.PackPath
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

object PackPathSerialization: KSerializer<PackPath> {

    override val descriptor = PrimitiveSerialDescriptor("PackPath", PrimitiveKind.STRING)

    override fun serialize(encoder: Encoder, value: PackPath) {
        encoder.encodeString(value.absolutePathString)
    }

    override fun deserialize(decoder: Decoder): PackPath {
        return PackPath(decoder.decodeString())
    }

}